#include <iostream>
#include <cassert>
#include <vector>
#include <algorithm>
#include <sstream>
#include <list>
#include <stack>
#include <queue>
using namespace std;

struct ListNode {
     int val;
     ListNode *next;
     ListNode() : val(0), next(nullptr) {}
     ListNode(int x) : val(x), next(nullptr) {}
     ListNode(int x, ListNode *next) : val(x), next(next) {}
};
//打印链表
void displayList(ListNode *p){
    while( p ){
        cout<< p->val ;
        p = p->next;
        if(p) cout<<"->";
    }
    cout<<endl;
}


//解决方案类
class Solution {
public:
    int divide(int dividend, int divisor) {
        if(dividend == 0 )return 0;
        int cnt = 0;
        int sig = (dividend>>31) ^ (divisor>>31);  //符号判断 同号 ：0 
        int a = dividend,b=divisor;
        if(sig){ //
            if(a > 0) while( a > 0 ) {a += b;if(a>=0)cnt--;}
            else while( a < 0 ) {a += b;if(a<=0)cnt--;}
        } else {
            if(a > 0) while( a > 0 ) {a -= b;if(a>=0)cnt++;}
            else while( a < 0 ) {a -= b;if(a<=0)cnt++;}
        }
        return cnt;
    }
};

int main(){
    Solution sp;
    cout<<sp.divide(-3,-1)<<endl;
    return 0;
}